package com.heima.datastructure.binarysearchtree;

/**
 * <strong>二叉搜索树的树节点</strong>
 * @param <K> key的数据类型，实现比较的接口，而且key不重复唯一
 * @param <V> value的数据类型，用于存值，存数据
 * @author 勾新杰
 * @version 1.0
 * @date 2024/9/9 11:05
 */
public class BSTNode<K extends Comparable<K>, V> {
    public K key;
    public V value;
    public BSTNode<K, V> left;
    public BSTNode<K, V> right;

    public BSTNode(K key) {
        this.key = key;
    }

    public BSTNode(K key, V value) {
        this.key = key;
        this.value = value;
    }

    public BSTNode(K key, V value, BSTNode<K, V> left, BSTNode<K, V> right) {
        this.key = key;
        this.value = value;
        this.left = left;
        this.right = right;
    }

    @Override
    public String toString() {
        return "[" + "key：" + key.toString() + " " + "value：" + value.toString() + "]";
    }
}
